package org.icress.fusion.b2b
import org.icress.fusion.shiro.User
import org.apache.shiro.SecurityUtils

class BomDetailService {

    static transactional = true

    def save(bomDetailInstance) {
        //get user
        def currentUser = User.findByUsername( SecurityUtils.getSubject().getPrincipal() )
        
        //set instance params
        bomDetailInstance.createdBy = currentUser
        bomDetailInstance.lastModifiedBy = currentUser
        bomDetailInstance.owner = currentUser
        
        //validate
        bomDetailInstance.validate()
        
        //save
        bomDetailInstance.save(flush: true)

    }
    
    def update(bomDetailInstance) {
        //get user
        def currentUser = User.findByUsername(SecurityUtils.getSubject().getPrincipal())
        
        //set instance params
        bomDetailInstance.lastModifiedBy = currentUser
        bomDetailInstance.lastUpdated = new java.util.Date()
        
        //validate
        bomDetailInstance.validate()
        
        //save
        bomDetailInstance.save(flush: true)
    }
}
